package com.home.entity;

import com.home.base.util.DateUtil;
import lombok.*;

import java.time.LocalDate;
import java.util.Date;
import javax.persistence.*;


@Builder(toBuilder = true)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@NoArgsConstructor
@Getter
@Setter
@Table(name = "job_user")
public class JobUser {
    /**
     * ID
     */
    @Id
    private Long id;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 姓名
     */
    private String name;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 航空公司
     */
    private String airline;

    /**
     * 航班号
     */
    @Column(name = "flight_number")
    private String flightNumber;

    /**
     * 目的地
     */
    @Column(name = "destination_city")
    private String destinationCity;

    /**
     * 状态
     */
    private String status;

    /**
     * 出发时间
     */
    @Column(name = "depart_time")
    private Date departTime;

    @Transient
    private String statusDesc;


    public void setStatus(String status){
        this.status=status;

        if(status.equals("0")) {
            if(departTime==null){
                statusDesc = "未使用";
            }else  if(DateUtil.getLocalDateByDate(departTime).isBefore(LocalDate.now())){
                statusDesc = "已过期";
            }else{
                statusDesc = "未使用";
            }
        }else {
            statusDesc = "已使用";
        }

    }

}
